﻿using System.Collections.Generic;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;


namespace projetSupinfoBFG.Base
{
    class TextureManager
    {
        Dictionary<string, Texture2D> textureBank = new Dictionary<string, Texture2D>();
        ContentManager content;
        
        public Texture2D GetTexture(string assetName)
        {
            if (textureBank.ContainsKey(assetName))
                return textureBank[assetName];
            else
            {
                textureBank.Add(assetName, content.Load<Texture2D>(assetName));
                return textureBank[assetName];
            }
        }


        #region Singleton

        private static TextureManager _theUniqueInstance = null;

            private TextureManager(ContentManager content) {
                this.content = content;
            }

            public static TextureManager GetInstance(ContentManager content)
            {
                if (_theUniqueInstance == null)
                    return _theUniqueInstance = new TextureManager(content);
                else
                    return _theUniqueInstance;
            }
        
            public static TextureManager GetInstance()
            {
                    return _theUniqueInstance;
            }

        #endregion



    }
}
